package com.bjdd.jdy.ui.dealRecord;

import com.bjdd.jdy.util.JumpUtil;
import com.bjdd.jdy.util.L;
import com.bjdd.jdy.util.SpUtil;
import com.bjdd.jdy.util.T;

/**
 * Created by Administrator on 2017/5/10.
 */

public class DealRecordPresenter extends DealRecordContract.Presenter {
    @Override
    public void onStart() {
        if (SpUtil.getUser() == null || SpUtil.getUser().equals("") || SpUtil.getUser().getCarrierId() == null) {
            JumpUtil.toLogin(context);
            return;
        }
    }

    @Override
    void getAcount(int page, int size) {
        showLoadingDialog(false);
        String token = SpUtil.getToken();
        String carrierId = SpUtil.getUser().getCarrierId();
        L.d("用户名："+carrierId);
        rxManager.add(model.getAcoount(token,carrierId,page,size)
        .subscribe(result -> {
            hideLoadingDialog();
            if (!result.isError()){
                view.acountSuccess(result.getData());
            }else {
                T.show(result.getMsg());
            }
        },e -> {
            hideLoadingDialog();
            T.show("获取数据失败");
            L.d("错误："+e.getMessage());
        }));
    }
}
